import request from '@/utils/request';
import config from "@/config";

// 接口地址
const url = {
    SysAuthUserSaveUrl: `${config.domain}/sys/auth-user/save`,
    SysAuthUserDeleteUrl: `${config.domain}/sys/auth-user/delete`,
    SysAuthUserListUrl: `${config.domain}/sys/auth-user/list`,
    SysAuthUserGetUrl: `${config.domain}/sys/auth-user/get`
};


export async function save(params) {
    return request(url.SysAuthUserSaveUrl, {
        method: "POST",
        body: params
    });
}

export async function del(id) {
    let data = {
        idList: id.key
    };
    return request(url.SysAuthUserDeleteUrl, {
        method: "DELETE",
        body: data
    });
}

export async function list(params) {
    const { pageSize, currentPage, ...searchData } = params || {};
    let reqBody = {
        size:pageSize || 10,
        current: currentPage || 0,
        search: searchData || {},
        ascs: [],
        descs: []
    };
    console.log(reqBody);
    return request(url.SysAuthUserListUrl, {
        method: "POST",
        body: reqBody
    });
}

export async function get(params) {
    return request(url.SysAuthUserGetUrl + `/${params.id}`);
}

